package com.rainng.coursesystem.module.custom.controller;

import com.rainng.coursesystem.base.api.dto.BaseIdReqDTO;
import com.rainng.coursesystem.controller.BaseController;
import com.rainng.coursesystem.model.vo.response.ResultVO;
import com.rainng.coursesystem.module.custom.dto.request.CustomUserReqDTO;
import com.rainng.coursesystem.module.custom.entity.CustomUser;
import com.rainng.coursesystem.module.custom.service.CustomUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("v2/sys/customuser")
public class CustomUserController extends BaseController {

    @Resource
    private CustomUserService basemapper;

    /**
     * 客户管理中，客户信息的新增
     * @param reqDTO
     * @return
     */
    @PostMapping ("/save")
    public ResultVO save(@RequestBody CustomUserReqDTO reqDTO){
        basemapper.save(reqDTO);
        return super.result();
    }

    @PostMapping("/delete")
    public ResultVO delete(@RequestBody BaseIdReqDTO reqDTO){
        basemapper.removeById(reqDTO.getId());
        return super.result("删除成功！");
    }

    @PostMapping("/detail")
    public ResultVO<CustomUser> detail(@RequestBody BaseIdReqDTO reqDTO){
        CustomUser cus = basemapper.getById(reqDTO.getId());
        return super.result(cus);
    }

}
